home *** CD-ROM | disk | FTP | other *** search
- Path: athos.cc.bellcore.com!nyjets!papo
- From: papo@nyjets.NoSubdomain.NoDomain (Luis R Anaya)
- Newsgroups: comp.lang.pl1,comp.lang.c
- Subject: Re: PL/I and C
- Date: 28 Feb 1996 21:04:31 GMT
- Organization: Bell Communications Research
- Distribution: world
- Message-ID: <4h2g0v$qgg@athos.cc.bellcore.com>
- References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <312CCEB2.4AB7@corp.dialog.com> <AD536AAB9668B76CD@mcdialb09.it.luc.edu> <312E363C.3CDE@corp.dialog.com> <mjs.825113139@hubcap> <AD568EA19668920AE@mcdiala11.it.luc.edu> <Pine.A32.3.91.960226003048.19148A-100000@black.weeg.uiowa.edu>
- NNTP-Posting-Host: nyjets.bigcat.bellcore.com
-
- In article <Pine.A32.3.91.960226003048.19148A-100000@black.weeg.uiowa.edu>, The Amorphous Mass <robinson@blue.weeg.uiowa.edu> writes:
- |> On Sun, 25 Feb 1996, Verne Arase wrote:
- |>
- |> > In article <mjs.825113139@hubcap>,
- |> > mjs@hubcap.clemson.edu (M. J. Saltzman) wrote:
- |>
- |> > >|> In fact, if I recall correctly a pointer to x is implicitly an array.
- |> > >
- |> > I was just explaining that in C, if you have a pointer, you also have an
- |> > array.
- |>
- |> If I declare char *ptr; in what sense have I gained an array?
-
- I disagree. when a pointer is declared you have a memory location.
- There is no array because no memory has been defined. There is
- no difference between
-
- int *foobar; DCL FOOBAR PTR;
-
- |> the difference between arrays and pointers, as does K&R2.
- |>
- |> * when the array occurs without []s as an rvalue, as in
- |> int *p, a[10];
- |> p = a;
- |> when it is operated on by the [] operator (a[6] becomes *(a + 6)),
- |> and when it is passed as a parameter in a function call.
-
- After memory has been declared... Otherwise, you will end up with
- a reference to never-never land and at the end a core dump (or ABEND).
-
- int *foobar;
- foobar = malloc (8*sizeof(int)); /* array of 0 to 7 */
-
- foobar [1]=2;
-
- ----
-
- DCL ZMEMORY (8); /* from 1 to 8 */
- DCL FOOBAR PTR BASED (ADDR (ZMEMORY));
-
- /* oh boy, am i rusty on PL/1 or what */
- /* I know that you can do this with REFER and controlled variables */
-
- Regards,
-
- --
- Luis Roberto Anaya-Rivera papo@donuts0.bellcore.com
- The Installator papo@bigcat.bellcore.com
- Bellcore, NJ n2zxe @ w2emu.nj.usa.na
-
-